import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
// import { default as Adal } from 'vue-adal'
import authentication from '@/utils/authentication'
import { formatDate } from '@/assets/js/date.js'
import '@/icons' // icon
import '@/permission' // permission control

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */
import { mockXHR } from '../mock'
if (process.env.NODE_ENV === 'production') {
  mockXHR()
}

// set ElementUI lang to zh-cn
Vue.use(ElementUI, { locale })

// use ADAL to authentication
// Vue.use(Adal, {
//   config: {
//     tenant: 'qdlspsp.onmicrosoft.com',
//     clientId: 'f333fc96-8cae-44c4-a943-599470fef28e',
//     redirectUri: 'http://localhost:9528',
//     cacheLocation: 'localStorage'
//   },
//   requireAuthOnInitialize: true,
//   router: router
// })

Vue.filter('formatDateSec', function(time) {
  var date = new Date(time)
  return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
})

Vue.config.productionTip = false
// Init adal authentication - then create Vue app.
authentication.initialize().then(_ => {
  /* eslint-disable no-new */
  new Vue({
    el: '#app',
    router,
    store,
    render: h => h(App)
  })
})
// new Vue({
//   el: '#app',
//   router,
//   store,
//   render: h => h(App)
// })
